<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../WEB-INF/facelets/layout.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui">
    <ui:param name="title" value="camelBlog"/>
    <ui:param name="headerTitle" value="camelBlog"/>
    <ui:define name="content">
        <p><h1> Welcome to the awesome camelBlog!</h1> </p>
        <p>
            This is a blog portal where you can create your own web blog.
        </p>
        <hr/>
        <!-- TO-Do -->
        <!-- Posts need to call something so that we can view them -->
        <h:form id="posts">  

            <c:forEach items="#{startViewBean.postList}" var="post">


                <h:link outcome="showPost" value="#{post.title}   " style="font-size: 2em">
                    <f:param name="postId" value="#{post.id}" />
                </h:link>
                <h:link outcome="showUser" value="#{post.userClass.userName}" >
                    <f:param name="userId" value="#{post.userClass.id}"/>
                </h:link> 



                <br/>
                <h:outputText value="#{post.postPreview}" style="word-wrap:break-word" />
                <hr/>
                <br/>
            </c:forEach>


        </h:form>    
        <h:form>
            <p:commandButton value="Show All" action="#{startViewBean.showAllPosts}"  update="posts"/>
        </h:form>
    </ui:define>
</ui:composition>
